package lnu.project.cart.content;

import lnu.project.cart.entity.Basket;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class BasketDatabaseHelper extends SQLiteOpenHelper implements
		BaseColumns {
	private static final String DATABASE_NAME = "lnuShoppingDB";
	public static final String DATABASE_TABLE = "baskets";
	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_CREATE = "create table "
			+ DATABASE_TABLE + " (" + Basket.ID
			+ " integer primary key autoincrement, " + Basket.NAME
			+ " text not null);";

	public BasketDatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
		onCreate(db);
	}
}
